package cn.agiledata.bank.barcodepayment.dao;

import java.util.Iterator;
import java.util.List;

import cn.agiledata.bank.hibernateBean.BarCodePayCorp;
import com.vnv.infrastructure.logic.IPBHibernate3BaseMgr;

public class BarCodePayCorpDaoImpl extends IPBHibernate3BaseMgr implements
		BarCodePayCorpDao {

	public List getBarCodePayCorpsByType(Long type) {
		String hql = "from BarCodePayCorp t where t.barCodePayType.id = ? order by t.orderNo asc";
		List list  = getHibernateService().find(hql, type);
		
		 Iterator it = list.iterator();
	        while(it.hasNext()){
	        	BarCodePayCorp corp = (BarCodePayCorp)it.next();
	        	//getSession().evict(corp);
	        	corp.getBarCodePayType();
	        }
	        return list;
	}

	public BarCodePayCorp getBarCodePayCorpsById(Long id) {
		String hql = "from BarCodePayCorp t where t.id = ?";
		return (BarCodePayCorp) getHibernateService().find(hql, id).get(0);
	}

	public BarCodePayCorp getBarCodePayCorpsByCode(String code) {
		String hql = "from BarCodePayCorp t where t.code = ?";
		return (BarCodePayCorp) getHibernateService().find(hql, code).get(0);
	}

    public List getBarCodePayCorpById(Long id) {
        String hql = "from BarCodePayCorp t where t.barCodePayType.id = ? order by t.orderNo asc";
        return getHibernateService().find(hql, id);
    }
    
    public List getBarCodePayCorps(){
    	String hql = "from BarCodePayCorp ";
        return getHibernateService().find(hql);
    }

}
